home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Scan / 64-bit_x64 / Russian / cpsimage.cab / data / sys / lang.elf < prev    next >
Text File  |  2009-04-23  |  9KB  |  172 lines

  1. /*
  2. ** $Id: lang.elf,v 1.11 2009/04/22 14:35:18 pemmett Exp $
  3. */
  4.  
  5. /******************************************************************************/
  6. /*
  7. ** This class provides progamatic access to the language.
  8. */
  9. /* @listClasses Returns a list of the current class type names. */
  10. /* @listProcedures Returns a list of the currently defined procedure names. */
  11. /* @listGlobals Returns a list of the currently defined global variable names. */
  12. /* @listLocals Returns a list of the currently defined local variable names. */
  13. /* @findClass Returns a CLASSREF object describing the given class. */
  14. /* @findProcedure Returns a CALLREF object describing the given procedure. */
  15. /* @findVariable Returns a STRING describing the type of the given variable. */
  16. /* @hasClass Does the given class exist. */
  17. /* @hasProcedure Does the given procedure exist. */
  18. /* @hasVariable Does the given variable exist. */
  19. /* @invokeProcedure Call the named procedure with the params given. Returns a LIST of the returns. */
  20. /* @setVariable Sets the named variable to the value given. */
  21. /* @getVariable Gets the named variable. */
  22. /* @New
  23.   // DESCRIPTION
  24.   Creates a new instance of a REFLECTION object. This object can be used to
  25.   progamatically access features of the language.  This includes the available classes,
  26.   procedures, local variables and global variables.
  27.  
  28.   // EXAMPLE's
  29.   #load "sys/lang.elf";
  30.  
  31.   LIST classes = REFLECTION.listClasses();
  32.   print classes;
  33.  
  34.   IMPORT STRING procname = "myproc";
  35.  
  36.   if( REFLECTION.hasProcedure( name:procname ) ) {
  37.     REFLECTION.invokeProcedure( name:procname );
  38.   }
  39. */
  40. /******************************************************************************/
  41. CLASS REFLECTION {
  42.     /* Static Methods */
  43.     METHOD New() RETURNS( REFLECTION obj ) NATIVE "ElfReflectMethods@builtins";
  44.     METHOD listClasses() RETURNS( LIST list ) NATIVE "ElfReflectMethods@builtins";
  45.     METHOD listProcedures() RETURNS( LIST list ) NATIVE "ElfReflectMethods@builtins";
  46.     METHOD listGlobals() RETURNS( LIST list ) NATIVE "ElfReflectMethods@builtins";
  47.     METHOD listLocals() RETURNS( LIST list ) NATIVE "ElfReflectMethods@builtins";
  48.  
  49.     METHOD findClass( STRING name ) RETURNS( CLASSREF ref ) NATIVE "ElfReflectMethods@builtins";
  50.     METHOD findProcedure( STRING name ) RETURNS( CALLREF ref ) NATIVE "ElfReflectMethods@builtins";
  51.     METHOD findVariable( STRING name ) RETURNS( STRING ref ) NATIVE "ElfReflectMethods@builtins";
  52.  
  53.     METHOD hasClass( STRING name ) RETURNS( BOOLEAN val ) NATIVE "ElfReflectMethods@builtins";
  54.     METHOD hasProcedure( STRING name ) RETURNS( BOOLEAN val ) NATIVE "ElfReflectMethods@builtins";
  55.     METHOD hasVariable( STRING name ) RETURNS( BOOLEAN val ) NATIVE "ElfReflectMethods@builtins";
  56.  
  57.     METHOD invokeProcedure( STRING name, LIST params ) RETURNS( LIST results ) NATIVE "ElfReflectMethods@builtins";
  58.     METHOD getVariable( STRING name ) RETURNS( OBJECT value ) NATIVE "ElfReflectMethods@builtins";
  59.     METHOD setVariable( STRING name, OBJECT value ) NATIVE "ElfReflectMethods@builtins";
  60. }
  61.  
  62. /******************************************************************************/
  63. /*
  64. ** This class provides progamatic access to a method or procedure.
  65. */
  66. /* @getName Returns the procedure or method name. */
  67. /* @listParameters Returns a named LIST with the names and type names of the parameters. */
  68. /* @listReturns Returns a named LIST with the names and type names of the returns. */
  69. /******************************************************************************/
  70. CLASS CALLREF {
  71.     METHOD Empty() RETURNS( BOOLEAN empty ) NATIVE "ElfCallRefMethods@builtins";
  72.  
  73.     METHOD getName() RETURNS( STRING name ) NATIVE "ElfCallRefMethods@builtins";
  74.     METHOD listParameters() RETURNS( LIST list ) NATIVE "ElfCallRefMethods@builtins";
  75.     METHOD listReturns() RETURNS( LIST list ) NATIVE "ElfCallRefMethods@builtins";
  76.  
  77.     /* Private Fields */
  78.     VOID handle;
  79. }
  80.  
  81. /******************************************************************************/
  82. /*
  83. ** This class provides progamatic access to the language.
  84. */
  85. /* @getName Returns the class type name. */
  86. /* @isInstance Is the given object an instance of this class type. */
  87. /* @isAssignableFrom Is the given class a subclass of this class type. */
  88. /* @listFields Returns a LIST of the field names. */
  89. /* @listMethods Returns a LIST of the method names. */
  90. /* @findMethod Returns a CALLREF object describing the given method. */
  91. /* @hasMethod Does the given method exists. */
  92. /* @hasField Does the given field exists. */
  93. /* @newInstance Creates a new instance of this class type with the given params. */
  94. /* @invokeMethod Class the named method the given params. Obj may be omitted if this CLASSREF refers to a given obj. See New. */
  95. /* @getField Gets the value of the named field. Obj may be omitted if this CLASSREF refers to a given obj. See New. */
  96. /* @setField Sets the value of the named field. Obj may be omitted if this CLASSREF refers to a given obj. See New. */
  97. /* @New
  98.   // DESCRIPTION
  99.   Creates a new instance of a CLASSREF object. This object can be used to
  100.   progamatically access information about a class.  This includes the available
  101.   methods, fields and the constructor. A given object may be inspected or the
  102.   class type may be inspected when created with the REFLECTION.findClass call.
  103.   
  104.   // ARGUMENTS
  105.   OBJECT handle     An object to inspect.
  106.   
  107.   // EXAMPLE's
  108.   #load "sys/lang.elf";
  109.   
  110.   IMPORT STRING classname = "myclass";
  111.   
  112.   // Inspect the class type
  113.   CLASSREF cr = REFLECTION.findClass( name:classname );
  114.   OBJECT obj = cr.newInstance();    // no params
  115.   LIST list = ( filename:"foo", compression:1 );
  116.   
  117.   cr.invokeMethod( obj:obj, name:"magic", params:list );
  118.   
  119.   // Inspect a given object.
  120.   CLASSREF ncr = new(CLASSREF, handle:obj);
  121.   LIST methods = ncr.listMethods();
  122.   print methods;
  123. */
  124. /******************************************************************************/
  125. CLASS CLASSREF {
  126.     METHOD New( OBJECT handle ) RETURNS( CLASSREF obj ) NATIVE "ElfClassRefMethods@builtins";
  127.     METHOD Empty() RETURNS( BOOLEAN empty ) NATIVE "ElfClassRefMethods@builtins";
  128.  
  129.     METHOD getName() RETURNS( STRING name ) NATIVE "ElfClassRefMethods@builtins";
  130.     METHOD isInstance( OBJECT obj ) RETURNS( BOOLEAN val ) NATIVE "ElfClassRefMethods@builtins";
  131.     METHOD isAssignableFrom( CLASSREF cls ) RETURNS( BOOLEAN val ) NATIVE "ElfClassRefMethods@builtins";
  132.  
  133.     METHOD listMethods() RETURNS( LIST methods ) NATIVE "ElfClassRefMethods@builtins";
  134.     METHOD listFields() RETURNS( LIST fields ) NATIVE "ElfClassRefMethods@builtins";
  135.  
  136.     METHOD findMethod( STRING name ) RETURNS( CALLREF ref ) NATIVE "ElfClassRefMethods@builtins";
  137.  
  138.     METHOD hasMethod( STRING name ) RETURNS( BOOLEAN val ) NATIVE "ElfClassRefMethods@builtins";
  139.     METHOD hasField( STRING name ) RETURNS( BOOLEAN val ) NATIVE "ElfClassRefMethods@builtins";
  140.  
  141.     METHOD newInstance( LIST params ) RETURNS( OBJECT obj ) NATIVE "ElfClassRefMethods@builtins";
  142.  
  143.     /* Static Methods */
  144.     METHOD invokeMethod( OBJECT obj, STRING name, LIST params ) RETURNS( LIST results ) NATIVE "ElfClassRefMethods@builtins";
  145.     METHOD getField( OBJECT obj, STRING name) RETURNS( OBJECT value ) NATIVE "ElfClassRefMethods@builtins";
  146.     METHOD setField( OBJECT obj, STRING name, OBJECT value ) NATIVE "ElfClassRefMethods@builtins";
  147.  
  148.     /* Private Fields */
  149.     OBJECT handle;
  150. }
  151.  
  152. /******************************************************************************/
  153. /*
  154. ** This class provides progamatic access to the debugger.
  155. */
  156. /* @attach Attaches current execution to a debugger. Can be done only once. NOTE: this method
  157.    is still very experimental and is really not working.  Do not play with this unless you know what
  158.    you are doing.
  159. */
  160. /* @isDebugging Is the current execution attached to a debugger. */
  161. /* @log Logs a message to the active debugger. Is a no op if no debugger is attached. */
  162. /* @printStackTrace Prints the current stack trace, does not have to be attached to work. */
  163. /******************************************************************************/
  164. private
  165. CLASS DEBUGGER {
  166.     /* Static Methods */
  167.     METHOD attach( STRING url ) NATIVE "ElfDebuggerMethods@builtins";
  168.     METHOD isDebugging() RETURNS( BOOLEAN isdebug ) NATIVE "ElfDebuggerMethods@builtins";
  169.     METHOD log( STRING msg ) NATIVE "ElfDebuggerMethods@builtins";
  170.     METHOD printStackTrace() NATIVE "ElfDebuggerMethods@builtins";
  171. }
  172.